var getTwoBit = function(n) {
  return (n > 9 ? '' : '0') + n
}
//去掉<br>
function replaceBr(value) {
  if (value == '' || isNull(value)) {
    return value
  } else {
    var reg = new RegExp(/<br>/, 'g')
    var formatBr = value.replace(reg, '  ')
    return formatBr
  }
}

function selectNumFilter(value) {
  var readStatusCh = value
  switch (value) {
    case '0':
      readStatusCh = '否'
      break
    case '1':
      readStatusCh = '是'
      break
  }
  return readStatusCh
}
//将日期转化为 年月日
function formatTimeToCon(value) {
  var date = new Date(value)
  var y = date.getFullYear()
  var m = getTwoBit(date.getMonth() + 1)
  var d = getTwoBit(date.getDate())
  return `${y}年${m}月${d}日`
}
//历史数据-电线积冰灾害
function filterLineDw(value) {
  var readStatusCh = value
  switch (value) {
    case 999999:
      readStatusCh = '缺测'
      break
    case 999998:
      readStatusCh = '不观测和无数据 '
      break
    case 999990:
      readStatusCh = '微量'
      break
  }
  return readStatusCh
}
function filterTime(value) {
  var readStatusCh = value
  let arr = readStatusCh.split('-')
  return arr[0] + '-' + arr[1] + '-' + arr[2]
}
function toFixedTwo(value) {
  return value.toFixed(2)
}
export {
  replaceBr,
  selectNumFilter,
  formatTimeToCon,
  filterLineDw,
  filterTime,
  toFixedTwo,
}
